package com.voice.qian.util;

import android.content.Context;
import android.widget.Toast;

import com.iflytek.cloud.InitListener;
import com.iflytek.cloud.RecognizerResult;
import com.iflytek.cloud.SpeechError;
import com.iflytek.cloud.ui.RecognizerDialog;
import com.iflytek.cloud.ui.RecognizerDialogListener;

/**
 * Author： RonQian
 * 创建日期：2017/9/7
 * 实现的主要功能：
 * 修改记录：
 */

public class MyRecognizerDialogLister extends RecognizerDialog implements RecognizerDialogListener {
    private Context context;

    public MyRecognizerDialogLister(Context context, InitListener initListener) {
        super(context, initListener);
    }

    @Override
    public void onResult(RecognizerResult recognizerResult, boolean b) {
        String trans = JsonParser.parseIatResult(recognizerResult.getResultString());
        Toast.makeText(context, trans, Toast.LENGTH_LONG).show();
    }

    @Override
    public void onError(SpeechError speechError) {
        int errorCode = speechError.getErrorCode();
        switch (errorCode) {
            case 10018:
                Toast.makeText(context, "没有数据", Toast.LENGTH_LONG).show();
                break;
            case 10204:
                Toast.makeText(context, "发送", Toast.LENGTH_LONG).show();
                break;
        }
    }

}
